﻿@model CommentDTO
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<section class="layui-larry-box">
    <div class="larry-personal">
        <header class="larry-personal-tit">
            <span>添加商品属性</span>
        </header><!-- /header -->

        <div class="larry-personal-body clearfix">
            <form class="layui-form col-lg-5" action="" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">商品名称</label>
                    <div class="layui-input-block">
                        <input type="hidden" name="Id" value="@Model.Id" />
                        <input type="hidden" name="GoodId" value="@Model.GoodId" />
                        <input type="text" value="@Model.GoodName" disabled autocomplete="off" class="layui-input" placeholder="请输入商品名称">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">订单号</label>
                    <div class="layui-input-block">
                        <input type="hidden" name="OrderId" value="@Model.OrderId" />
                        <input type="text" name="" value="@Model.OrderId" disabled autocomplete="off" class="layui-input" placeholder="请输入商品原始价格">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">评论等级</label>
                    <div class="layui-input-block">

                        <input type="text" name="Level" value="@Model.Level" autocomplete="off" class="layui-input" placeholder="请输入商品原始价格">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">评论者</label>
                    <div class="layui-inline">
                        <input type="hidden" name="UserId" value="@Model.UserId" />
                        <input type="text" disabled value="@Model.UserName" lay-verify="required" autocomplete="off" class="layui-input " placeholder="请输入管理员昵称">
                    </div>

                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">评论图片</label>
                    <div class="layui-inline">
                        <input type="hidden" name="CommentImgSrc" value="@Model.CommentImgSrc" />
                        <img width="100" height="100" src="@Model.CommentImgSrc" />
                    </div>
                  
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">评论内容</label>
                        <div class="layui-input-block">
                            <textarea name="Content" placeholder="既然选择了远方，便只顾风雨兼程；路漫漫其修远兮，吾将上下而求索" value="" class="layui-textarea">@Model.Content</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="editBtn">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>




</section>


@section FooterScript{

    <script src="~/common/layui/layui.all.js"></script>

  
    <script>

        layui.use(['jquery', 'layer', 'element', 'laypage', 'form'], function () {
            window.jQuery = window.$ = layui.jquery;
            window.layer = layui.layer;
            var laypage = layui.laypage;
            var form = layui.form;

            //此处的editBtn代码中提交按钮的 lay-filter属性
            form.on("submit(editBtn)", function (data) {

                var index = top.layer.msg('数据提交中，请稍候', { icon: 16, time: false, shade: 0.8 });

                var formData = $(".layui-form").serialize();    //表单数据

                $.ajax({
                    url: "/Comment/Edit",
                    method: "post",
                    dataType: "json",
                    data: formData,
                    //traditional: true,//这里设置为true
                    success: function (res) {
                        if (res.status == "ok") {
                            layer.msg("添加成功", {
                                icon: 1, time: 1000, end: function () {
                                    top.layer.close(index);
                                    layer.closeAll("iframe");
                                    //刷新父页面
                                    parent.location.reload();
                                }
                            });



                        } else {
                            layer.msg("添加失败:" + res.errorMsg, {
                                icon: 5, time: 2000, end: function () {
                                    top.layer.close(index);
                                    layer.closeAll("iframe");
                                    //刷新父页面
                                    parent.location.reload();
                                }
                            });
                        }
                    },
                    error: function () {
                        layer.msg("网络请求失败", {
                            icon: 5, time: 2000, end: function () {
                                top.layer.close(index);
                                layer.closeAll("iframe");
                                //刷新父页面
                                parent.location.reload();
                            }
                        });
                    }
                });

                return false;
            })
        });




    </script>

}

